package com.test.study.ToolsUtils.strom.workdsum;

import java.util.Map;

import org.apache.storm.task.OutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseRichBolt;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;

@SuppressWarnings("serial")
public class GoloaBolt extends BaseRichBolt {
	
@SuppressWarnings({ "unused", "rawtypes" })
private Map stormConf;
@SuppressWarnings("unused")
private TopologyContext context;
@SuppressWarnings("unused")
private OutputCollector collector;


	@SuppressWarnings("rawtypes")
	@Override
	public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
		this.stormConf=stormConf;
		this.context=context;
		this.collector=collector;
	}

	@Override
	public void execute(Tuple input) {
		String stringByField = input.getStringByField("line");
		if(stringByField!=null && stringByField.length()>0) {
			String[] splits = stringByField.split("\t");
			if(splits!=null && splits.length>0) {
				for (String split : splits) {
					this.collector.emit(new Values(split));
					
				}
			}
		}

	}

	@Override
	public void declareOutputFields(OutputFieldsDeclarer declarer) {
		declarer.declare(new Fields("word"));
	}

}
